<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/global.js"></script>
<script language="javascript" src="${ctx}/scripts/common/prototype.js"></script>

<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common.js"></script>

<link href="${ctx}/styles/listTable.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/show.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/styles/public.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<script language="JavaScript"  src="${ctx}/scripts/ajaxException.js"></script>

<script type="text/javascript">
	var houseId = null;
	var houseNum = null;
	var index = null;

	var flag_button_click = null;

	function openHouseAdd(){
		setFlagButtonClick(true);
		var url = '${ctx}/customer_ownerAction.do?method=initOwnerHouseAdd';
		top.windowOpen(url, 'houseChoose', '选择房间信息',380,470,false,"houseChooseFrame");
	}
	function openHouseEdit(){
		if(houseId == null) {
			Alert("请选择一个房间");
			return;
		}
		setFlagButtonClick(true);
		var url = '${ctx}/customer_ownerAction.do?method=initOwnerHouseEdit&edit_houseId=' + houseId;
		top.windowOpen(url,"houseEditFrm","修改住房信息",380,470);
	}
	function openHouseDelete(){
		if(index == null || index == ""){
			Alert("请选择一个房间");
			return;
		}
		setFlagButtonClick(true);
		AskConfirm("确定删除该记录吗？","ownerList","houseDelete");
	}
	function houseDelete(){
		var url = "${ctx}/customer_ownerAction.do?method=deleteCustomerHouseCache&houseId="+ houseId + "&houseNumber="+ houseNum +"&index=" + index;
		var myAjax = new Ajax.Request(url, {method: 'get', parameters: null, onComplete: houseDeleteCallBack});
		function houseDeleteCallBack(result){
			var obj = result.responseText;
			ajaxSubmitException(obj);
			if(obj == "isOneHouse"){
				Alert("最后一个房间,不能删除");
			}else if(obj == "false"){
				Alert("删除失败！");
			}else{
			    parent.setFamilyUnEdit();
				flushIframe(result);
			}
		}
	}

	function setHouseId(house_id){
		houseId = house_id;
	}
	function setHouseNum(houseNum_){
		houseNum = houseNum_;
	}
	function setIndex(index_){
		index = index_;
	}
	function flushIframe(originalRequest){
		var result = originalRequest.responseText;
		reLoadIframe();
	}
	function setFlagButtonClick(flag){
		flag_button_click = flag;
	}

//-------------------业主资料管理-----------
	var customerType = null;
	var ownerBaseIndex = null;
	function openOwnerAdd(){
		setFlagButtonClick(false);
		top.windowOpen('${ctx}/customer_ownerAction.do?method=initOwnerBaseAdd', 'ownerAddFrm', '新增业主资料',670,900,false,"ownerAddFrm");
	}

	function openOwnerEdit(){
		setFlagButtonClick(false);
		if(ownerBaseIndex == null || ownerBaseIndex == ""){
			Alert("请选择一条记录");
			return;
		}
		var url = "${ctx}/customer_ownerAction.do?method=initOwnerBaseEdit&ownerBaseIndex=" + ownerBaseIndex + "&customerTypeCode=" + customerType;
		top.windowOpen(url,'ownerEditFrm','修改业主资料',670,900,false,"ownerEditFrm");
	}

	function openDelete(){// open打开动作
		if(ownerBaseIndex == null){
			Alert("请选择一条记录");
			return;
		}
		AskConfirm("确定删除该记录吗？","ownerList","ownDelete");
	}
	function ownDelete(){//删除房间
		var str = "index=" + ownerBaseIndex;
		setFlagButtonClick(false);
		var myAjax = new Ajax.Request("${ctx}/customer_ownerAction.do?method=deleteOwnerBaseCache",
                   {method: 'post', parameters: str, onComplete: reLoadIframe}
                   );
	}

	function setVar(customerType_,ownerBaseIndex_){
		customerType = customerType_;
		ownerBaseIndex = ownerBaseIndex_;
	}

	function reLoadIframe(){
		if(flag_button_click)
			document.frames["ownerHouseListIframe"].location = "${ctx}/customer_ownerAction.do?method=findOwnerHouseCachePage&ec_p=1&ec_crd=5";
		document.frames["customerBaseIframe"].location = "${ctx}/customer_ownerAction.do?method=findOwnerBaseListCachePage&ec_p=1&ec_crd=3";
	}
</script>
</head>
<body>
<div style="overflow:auto; height:400px;">
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" id="tab_subMenu1">
                      <tr>
                        <td>
                        	<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
                            	<tr>
                              		<td>
                              			<table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color"  style="display:show">
					                        <tr>
					                          <td colspan="4" class="aux_titletable">住房信息</td>
					                        </tr>
                      					</table>
							  			<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab_line">
						                    <tr>
						                      	<td valign="top">
						                      		<table width="100%" border="0" cellspacing="0" cellpadding="0" >
                        								<tr>
              												<td class="bg_toolBar">
              													<table width="100%" border="0" cellspacing="0" cellpadding="0">
													                  <tr>
													                    	<td width="35%" align="right">
																			<table border="0" cellpadding="0" cellspacing="0" id="ico1">
													                      		<tr>
													                        		<td class="toolbarico">
													                        			<c:if test="${type == 'goOut'}"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新增"/></c:if>
													                        			<c:if test="${type!= 'goOut'}"><a href="#"  onclick="openHouseAdd();" onfocus="this.blur();">
													                        			<img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新增"/>&nbsp;</a></c:if>

													                        		</td>
													                            	<td  class="toolbarico" >
													                            		<a href="#" this.blur()" onClick="openHouseEdit();" onFocus="this.blur();">
													                            			<img src="${ctx}/images/ico_amend.gif" alt="修改" width="16" height="16" border="0" align="absbottom" /></a>
													                            	</td>
													                            	<td class="toolbarico">
													                            		<c:if test="${type == 'goOut'}"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom"></c:if>
													                            		<c:if test="${type != 'goOut'}"><a href="#" onClick="openHouseDelete();" onFocus="this.blur()">
													                            		<img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom"></a></c:if>
													                            	</td>
													          						<td  class="toolbarico">&nbsp;</td>
													                          	</tr>
													                      	</table>
																		  </td>
													                    </tr>
                												</table>
															</td>
             											</tr>
             										</table>
								              <tr>
								                <td colspan="5" >
								                	<iframe id="ownerHouseListIframe" frameborder="0"  src="${ctx}/customer_ownerAction.do?method=initOwnerHouseList" width="100%"></iframe>
												</td>
								               </tr>
                      </table></td>
                    </tr>
                </table>
				<table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color"  style="display:show">
                      <tr>
                        <td colspan="4" class="aux_titletable">业主资料</td>
                      </tr>
               </table>
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab_line">

            <tr>
              <td class="bg_toolBar">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="40%">&nbsp;</td>
                  <td width="60%" align="right"><!--------------------------右边图标01----------------------------------->
                    <table border="0" cellpadding="0" cellspacing="0" id="ico1">
                      <tr>
					  <td class="toolbarico"><a href="#"  onClick="openOwnerAdd();" onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="登记业主资料"/></a></td>
                        <td class="toolbarico"><a href="#"  onClick="openOwnerEdit();"onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改住户资料"/></a></td>
                        <td class="toolbarico"><a href="#" onClick="openDelete();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom"></a></td>
                      </tr>
                    </table>
                    <!--------------------------右边图标end----------------------------------->
                  </td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td colspan="5" >
               <iframe id="customerBaseIframe" frameborder="0" src="${ctx}/customer_ownerAction.do?method=initOwnerBaseList"  width="100%"></iframe>
  				</td>
          </tr>
      </table></td>
                      </tr>
                  </table></td>
                </tr>
              </table>
   </div>
</body>
</html>